I'm not sure that it is possible to change an action assigned to an entity.

There are two ways that I do know will get around the problem though....

1) Make your current model passable and create a new entity of the same model in that spot with your new action, then remove the original entity.

2) Use an entity skill to direct what actions get executed:


code:
--------------------------------------------------------------------------------

  ACTION DEMO
{
     IF (MY.SKILL1 = 1){SING_AND_DANCE();}
     IF (MY.SKILL1 = 2){ROMP_AND_PLAY();}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Bezier curves use 4 reference coordinates, two as the end points and two others to control the shape of the curve. Let the 4 points be (x0 y0), (x1 y1), (x2 y2) and (x3 y3). The curve starts out tangent to the line joining the first two points and ends up tangent to the line joining the second two points. The control points ``pull'' at the curve to control the curvature. The amount of pull increases with the distance of the control point from the endpoint. 
As the parameter u varies from 0 to 1, the coordinates of the Bezier curve are given by a pair of parametric cubic equations, 

x(u) = (1-u)^3 x0 + 3u (1-u)^2 x1 + 3u^2 (1-u) x2 + u^3 x3 y(u) = (1-u)^3 y0 + 3u (1-u)^2 y1 + 3u^2 (1-u) y2 + u^3 y3 . 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jcl

camera.x = player.x + cr * cos(cang);
camera.y = player.y + cr * sin(cang);
camera.pan = 360 - cang;

while cr is the radius of the circle (305 in your case) and cang is the camera position on the circle in the range of 0..360. The last line points the camera always to the player. 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
jcl  
Unregistered  
 

 
 
 
 
  Re: How to re-visit level ? 
      #214510 - Tue Aug 14 2001 05:37 PM   Edit     Reply     Quote    
 
 

The save method should do the trick, however there must be at least one frame between saving and loading:
save("temp",1);
wait(1);
load("temp",2);
wait(1);
load_level(<level2.wmb> ); // if load failed

The last line is necessary for the first time when "temp2" is not yet saved. 

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
Anyone knows what's wrong with this code?

code:
--------------------------------------------------------------------------------

/*Source code by: Maciej Miasik - Game Developer  www.schizm.com,  www.reah.com,  www.lkavalon.com (c) 2001 - Maciej Miasik - ALL RIGHTS RESERVED*/function move_view(){  player=me;  if(player==null) { return; }  camera.diameter=0;  camera.genius=player;// desired camera location relative to player  camPosition.x=-150;  // this is distance behind the player  camPosition.y=0;  camPosition.z=100;   // this is height above the player's head  lookTarget.x=10;  lookTarget.y=0;  lookTarget.z=(player.max_z-player.min_z)/2;// difference between player pan and camera pan  angleDistance=ang(player.pan-camAngles.pan);// check rotation margins and select direction of rotation  if(angleDistance>ROTATION_MARGIN) {    camChaseDir=1;  }  if(angleDistance<-ROTATION_MARGIN) {    camChaseDir=-1;  }  if(abs(angleDistance)<3) {// stop rotation the camera is almost behind    camChaseDir=0;    cameraRotationSpeed=0;  }  if(camChaseDir!=0) {// rotate camera    camAngles=ang(camAngles+camChaseDir*time*cameraRotationSpeed);// change rotation speed    if(abs(player._ASPEED)>cameraRotationSpeed) {// but not faster than player rotation      cameraRotationSpeed+=2*time;    }  }  vec_rotate(camPosition,camAngles);// calculate desired camera position  vec_set(myTemp,player.x);  vec_add(camPosition,myTemp);  vec_rotate(lookTarget,camAngles);  vec_add(lookTarget,player.x);// check camera position for solid blocks  trace_mode=ignore_you+ignore_me+ignore_passable+ignore_passents;  blockDistance=trace(lookTarget,camPosition);// if camera moved into a wall...  if(blockDistance!=0) {// move it closer to the player    vec_set(camPosition,target);    if(blockDistance<=TRANSP_DISTANCE) {      my.transparent=on;      my.alpha=(blockDistance/(TRANSP_DISTANCE-10))*100+10;    }  }  if((blockDistance>TRANSP_DISTANCE)||(blockDistance==0)) {    my.transparent=off;    my.alpha=100;  }  vec_set(camera.x,camPosition);  vec_set(myTemp,lookTarget);  vec_sub(myTemp,camera.x);  vec_to_angle(camera.pan,myTemp);}

--------------------------------------------------------------------------------

I get four errors saying: "Parameter (name) unknown keyword"

Thanks in advance,

Nemo 

Post Extras:           
 
al1  
Expert  
  
 
 
Reged: May 17 2001  
Posts: 1201  
Loc: Outarville, France  
  Re: Elegant way to prevent the camera bouncing of the wall? 
      #214622 - Thu Aug 16 2001 12:54 AM   Edit     Reply     Quote    
 
 


quote:
--------------------------------------------------------------------------------
Originally posted by Nemo:
Anyone knows what's wrong with this code?


--------------------------------------------------------------------------------

yes, i know.

It is simply necessary to declare variables previously. I used it in office, it is great

var camPosition[3];
var lookTarget[3];
var angleDistance;
var camChaseDir;
var camAngles;
var rotation_margin;
var cameraRotationSpeed;
var camAngles;
var blockDistance;
var transp_distance;
var myTemp;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 Elegant?!
No.

Here's a thought though... Do a trace from the player towards the camera, for a distance of the normal camera to player distance. If you hit
 a wall, NORMALIZE the vector length by a bit, and then position the camera at that spot normalized spot.

In my wiery brain, I'm thinking that this will always keep a camera from touching the wall.

Another option is to put antennae on the camera as illustrated by AUM4 (Nice job George!) and if the antenae hit the wall, the camera moves
 forward a little bit.

Let me know what direction you go, or better yet, post your code! I'll be needing to to this myself soon enough!

-WildCat 
 ----vec_normalize.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 
 

 
 
 
 
  Attn: NWkid3d - rope code is working 
      #214816 - Wed Aug 22 2001 04:06 PM   Edit     Reply     Quote    
 
 

I finally got the rope code to work. Turns out your code was correct. The rope code I got from George Pirvu's Acknex site is wrong.
His code has the gravity set to 0.01 in the while loop. By testing it I discovered that the correct setting is 0.00. I then looked in your code and saw you already have it set to the correct value. Ah well!
Conitec, please update the code at the Acknex site. 

Post Extras:           
 
**DONOTDELETE**  
 
 

 
 
 
 
  Re: Attn: NWkid3d - rope code is working 
      #214817 - Wed Aug 22 2001 04:35 PM   Edit     Reply     Quote    
 
 

tman,
Awesome bro, I'm glad you got it working. I think George was trying to have some negative drift(gravity) to the ladder/rope. 

But what I found is when you have a small entity such as a rope, the gravity pull could move you out of the range:

(skill10 < skill1)

if you move to your left or right by accident. Most desirable setting is 0.00.

My main concern with any code I help tweak, write or explain, is to get you effective code that does what you want or close to it. Then you don't have to worry about it and move on, thus, accelerating your goal:

Completing your project(game)

Glad I could help...

Bill  

Post Extras:           
 
**DONOTDELETE**  
 
 

 
 
 
 
  Re: Attn: NWkid3d - rope code is working 
      #214818 - Wed Aug 22 2001 05:02 PM   Edit     Reply     Quote    
 
 

speaking of (skill10 < skill1). I tweaked the settings a bit and discovered something interesting.
try to go halfway up your rope or ladder and then try to walk or back away from it. this will in effect break the first If loop. when this happens you will notice that gravity is still at zero, and you float in the air. the reason this happens is because when you break out of the first loop you also break out of the second loop, which is the one that 'restores' your gravity. to fix this is simple. I just copied the "gravity = gravity_temp;" and added it right under "my.skill10 = 0; // reset distance".

I tested it with my skill1 set to 300 and it worked great...for both the rope AND the ladder.

nice script bro.
thx again for your help. 

Post Extras:           
 
**DONOTDELETE**  
 
 

 
 
 
 
  Re: Attn: NWkid3d - rope code is working 
      #214819 - Wed Aug 22 2001 11:41 PM   Edit     Reply     Quote    
 
 

Hi,
"The rope code I got from George Pirvu's Acknex site is wrong. His code has the gravity set to 0.01 in the while loop.."

The code works fine with gravity set to 0.01 on all my PCs - you can set it to 0 if this makes it work for you; gravity = 0 was causing some problems with older template files. 

All the scripts in AUM are tested by me and Conitec before they are posted. 


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
how do you attach a camera to an element?
where are you Marty  

--------------------
In the End, its all about the GAME! 

Post Extras:           
 
Eagle  
Expert  
  
 
 
Reged: Sep 26 2000  
Posts: 1067  
Loc: The World  
  Re: how do you attach a camera to an element? 
      #214763 - Wed Aug 22 2001 10:27 PM   Edit     Reply     Quote    
 
 

..thanks for the help 

--------------------
In the End, its all about the GAME! 

Post Extras:            
**DONOTDELETE**  
 
 

 
 
 
 
  Re: how do you attach a camera to an element? 
      #214764 - Wed Aug 22 2001 11:41 PM   Edit     Reply     Quote    
 
 


code:
--------------------------------------------------------------------------------

//based on keebo's overhead cam script///////////
eaglecam
SYNONYM cam_syn {TYPE entity;}
//you need this to identify the object			      
//you are going to attach the script to

ACTION eagle_cam 
{
//attach this to your object	
cam_syn = ME;	
wait (1);}
VIEW mover_view 
{	
POS_X 40;//where at on the screen horizontally	
POS_Y 10;//where at vertically	
SIZE_X 80;//camera view x size	
SIZE_Y 80;//camera view y size	
LAYER 1.1;	
DIAMETER 0;
} 

SKILL	CenterMeOH { X 5; Y 0; Z 0; }
function mover_cam() 
{  IF (mover_view.VISIBLE == ON)
{	SET mover_view.VISIBLE,OFF;	
}
 ELSE 
{	
SET mover_view.VISIBLE,ON;	
}	
WHILE (1)
 {		
CenterMeOH.X = 10;		
CenterMeOH.Y = 0;		
CenterMeOH.Z = 0;		
MOVE	ME,CenterMeOH,nullskill;		
WAIT	1;  
mover_view.X = cam_syn.X;  
mover_view.Y = cam_syn.Y; 
 mover_view.Z = cam_syn.Z+5;  
mover_view.PAN = 0;  
mover_view.TILT = 0;  
mover_view.ROLL = 0;  
 }
}
ON_V mover_cam;

--------------------------------------------------------------------------------

hope this gets you started, Keebo did the original camera code and George Pirvu explained synonyms (for attaching stuff to entities and models) in AUM1... 

Post Extras:           
 
Eagle  
Expert  
  
 
 
Reged: Sep 26 2000  
Posts: 1067  
Loc: The World  
  Re: how do you attach a camera to an element? 
      #214765 - Thu Aug 23 2001 04:50 AM   Edit     Reply     Quote    
 
 

Thank you Marty!!!
You are great! 
This will help me a bunch!!!

your friend, 

--------------------
In the End, its all about the GAME! 

Post Extras:           
 
**DONOTDELETE**  
 
 

 
 
 
 
  Re: how do you attach a camera to an element? 
      #214766 - Thu Aug 23 2001 05:52 AM   Edit     Reply     Quote    
 
 

AUM1 (Acknex User Magazine, I believe its number one) also has the camera views code from George. 



 
2bit  
Member  
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  

 
Reged: Aug 22 2001  
Posts: 243  
Loc: Alberta, Canada  
  Need a HUGE favour done for me..... 
      #214869 - Fri Aug 24 2001 02:19 AM   Edit     Reply     Quote    
 
 

As you all know i am making a mario 64 style game.. But what i rreeeally need is a camera script that is verrry similair to the one in mario 64 or tomb rainder. If you cant supply me with a full one just give me some suggestions. Anyone help.....
Thanks  

Post Extras:            
**DONOTDELETE**  
 
 

 
 
 
 
  Re: Need a HUGE favour done for me..... 
      #214870 - Fri Aug 24 2001 04:30 AM   Edit     Reply     Quote    
 
 

there are several camera scipts aviable on some of pages on the links page. 

Post Extras:            
2bit  
Member  
  

 
Reged: Aug 22 2001  
Posts: 243  
Loc: Alberta, Canada  
  Re: Need a HUGE favour done for me..... 
      #214871 - Fri Aug 24 2001 05:31 AM   Edit     Reply     Quote    
 
 

i guess i will check thanx  

Post Extras:            
**DONOTDELETE**  
 
 

 
 
 
 
  Re: Need a HUGE favour done for me..... 
      #214872 - Fri Aug 24 2001 01:10 PM   Edit     Reply     Quote    
 
 

someone gave me this tomb raider style script a while ago, maybe it will help.

code:
--------------------------------------------------------------------------------

 SKILL player_velocity {}SKILL camera_velocity {}SKILL player_direction {}SKILL player_angle {}SKILL relative_radius {VAL 300;}SKILL absolute_radius {VAL 300;}SKILL camera_tilt {}SKILL camera_blocked_mode {}SKILL relative_player_angle {}SKILL relative_camera_angle {}ACTION chase_camera {MY.UNLIT = ON;MY.AMBIENT = 80;	WHILE (1) {		IF (KEY_INS == 0) {			MY.PAN -= 3 * KEY_FORCE.X;			player_velocity.X = 10 * TIME * KEY_FORCE.Y;			player_velocity.Y = 0;			player_velocity.Z = 0;			MOVE ME, player_velocity,NULLSKILL;					CALL move_camera_auto;		}		IF (KEY_INS == 1) {		CALL move_camera_free;		}		IF ((KEY_FORCE.Y != 0 && KEY_INS == 0) || (KEY_FORCE.X != 0 && KEY_INS == 0)) {			MY.CYCLE += 2 * TIME;			IF (MY.CYCLE >= 30) {MY.CYCLE = 2;}		}		IF (KEY_FORCE.X == 0 && KEY_FORCE.Y == 0) {			MY.CYCLE = 1;		}		WAIT 1;	}}ACTION move_camera_auto {	player_direction.X = MY.X - CAMERA.X;	player_direction.Y = MY.Y - CAMERA.Y;	player_direction.Z = MY.Z - CAMERA.Z;	TO_ANGLE  player_angle, player_direction;	CAMERA.PAN = player_angle.PAN;	CAMERA.TILT = player_angle.TILT + camera_tilt;	IF (KEY_FORCE.Y > 0 && camera_blocked_mode == 1) {camera_blocked_mode = 0;}		SHOOT MY.POS, CAMERA.POS;	IF (RESULT != 0) {		camera_blocked_mode = ABS (camera_blocked_mode - 1);	}	IF (camera_blocked_mode == 0){ relative_player_angle = MY.PAN;}	IF (camera_blocked_mode == 1){ relative_player_angle = (MY.PAN - 180);}	camera_velocity.X = .1 * (MY.X - absolute_radius * COS(relative_player_angle) - CAMERA.X);      camera_velocity.Y = .1 * (MY.Y - absolute_radius * SIN(relative_player_angle) - CAMERA.Y);	IF (relative_radius >= 270) {		camera_velocity.Z = .03 * (MY.Z + (MY.MAX_Z + 3) - CAMERA.Z);	} ELSE {		IF (camera_blocked_mode == 0) {			camera_velocity.Z = 3;		}		IF (camera_blocked_mode == 1) { 			camera_velocity.Z = .03 * (MY.Z + (MY.MAX_Z + 3) - CAMERA.Z);		}		IF (CAMERA.Z >= MY.Z + 300) {camera_velocity.Z = 0;}	}	MOVE_VIEW CAMERA,NULLSKILL,camera_velocity;	relative_radius = ABS (SQRT(((MY.X - CAMERA.X)*(MY.X - CAMERA.X)) + ((MY.Y - CAMERA.Y)*	(MY.Y - CAMERA.Y))));	IF (relative_radius < 250) {		camera_tilt = camera_tilt + .5;		IF (camera_tilt >= 10) {camera_tilt = 10;}	}	IF (relative_radius >= 250) {		camera_tilt = camera_tilt - .5;		IF (camera_tilt <= 0) {camera_tilt = 0;}	}	IF (relative_radius >= 400) {		CAMERA.DIAMETER = 0;	} ELSE {		CAMERA.DIAMETER = 1;	}	relative_camera_angle = relative_player_angle;}ACTION move_camera_free {	player_direction.X = MY.X - CAMERA.X;	player_direction.Y = MY.Y - CAMERA.Y;	player_direction.Z = MY.Z - CAMERA.Z;	TO_ANGLE  player_angle, player_direction;	CAMERA.PAN = player_angle.PAN;	CAMERA.TILT = player_angle.TILT;	relative_camera_angle -= 5 * KEY_FORCE.X;	camera_velocity.X = .2 * (MY.X - absolute_radius * COS(relative_camera_angle) - CAMERA.X);      camera_velocity.Y = .2 * (MY.Y - absolute_radius * SIN(relative_camera_angle) - CAMERA.Y);	camera_velocity.Z =  5 * KEY_FORCE.Y;	IF (CAMERA.Z >= MY.Z + 200 && KEY_FORCE.Y >= 0) {camera_velocity.Z = 0;}	MOVE_VIEW CAMERA,NULLSKILL,camera_velocity;} 

--------------------------------------------------------------------------------



Post Extras:            
Eagle  
Expert  
  
 
 
Reged: Sep 26 2000  
Posts: 1067  
Loc: The World  
  Re: Need a HUGE favour done for me..... 
      #214873 - Fri Aug 24 2001 08:12 PM   Edit     Reply     Quote    
 
 

This is Cool! thanks Goddardl,
I have a question for you. 
How do you use this code? 
Do You;
a) place code at end of main wdl ?
b) save it as its own wld file and include it to your main wdl
c) add it to another wld file not listed here?
d) none of the above...
please help 

your friend, 

--------------------
In the End, its all about the GAME! 

Post Extras:           
 
2bit  
Member  
  

 
Reged: Aug 22 2001  
Posts: 243  
Loc: Alberta, Canada  
  Re: Need a HUGE favour done for me..... 
      #214874 - Sat Aug 25 2001 01:43 AM   Edit     Reply     Quote    
 
 

Wow great.   



Ok,
here you go:


code:
--------------------------------------------------------------------------------

action my_circle {	while(1) {		emit(1,my.x,circle_particle);		wait(1);	}}function circle_particle(){	if(my_age == 0)	{		my_alpha=0;		my_color.red = random (255);		my_color.green = random (255);		my_color.blue = random (255);		my_pos.z=player.z;		my_size = 150+random(150);		my_transparent= on;		my_bright= on;		END;	} 	if (my_age > 45) {		MY_ACTION = NULL;	}	my_pos.x = player.x + sin (my_age*8) * 50;	my_pos.y = player.y + cos (my_age*8) * 50;	my_alpha=100;}

